﻿using OS.Infrastructure.Domain;

namespace TaskKernel.Domain
{
    public class Participant : AbstractEntity
    {
        protected Participant()
        {
        }

        public Participant(Task task, Account login, Account participant) : this()
        {
            Task = task;
            Login = participant;
            Owner = login;
        }

        public virtual Task Task { get; protected set; }
        public virtual Account Login { get; protected set; }
        public virtual Account Owner { get; protected set; }

        public override int GetHashCode()
        {
            int hashCode = 0;
            hashCode = hashCode ^ Login.GetHashCode();
            return hashCode;
        }

        public override bool Equals(object obj)
        {
            var toCompare = obj as Participant;
            if (toCompare == null)
                return false;
            return (GetHashCode() == toCompare.GetHashCode());
        }
    }
}